<template>
  <div class="addForm">
    <el-form status-icon label-width="200px" :model="bookData">
      <el-form-item label="书名">
        <el-input v-model="bookData.bookName"></el-input>
      </el-form-item>
      <el-form-item label="作者">
        <el-input v-model="bookData.author"></el-input>
      </el-form-item>
      <el-form-item label="出版日期">
        <el-input v-model="bookData.date"></el-input>
      </el-form-item>
      <el-form-item style="text-a">
        <el-button type="primary" @click.prevent="toSave">保存</el-button>
        <el-button @click.prevent="toBack">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { mapState } from "vuex";

export default {
  methods: {
    toBack() {
      this.$store.commit("clean");
      this.$router.push("/");
    },
    toSave() {
      console.log(this.bookData);
      this.$router.push("/");
    }
  },
  computed: {
    ...mapState(["bookData"])
  }
};
</script>
<style scoped>
.addForm {
  text-align: right;
}
</style>
